﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.OracleClient;

namespace OracleDAL.ResourceManage
{
    public class showAccecc
    {
        public DataSet accossList(string keyID, string tablename)
        {
            string column = "";
            string whereStr="";
            string[] arr;

            arr = keyID.Split('=');
            whereStr = arr[0] + "='" + arr[1] + "'";

            string strSql = "select user_tab_columns.column_name  as name from user_tab_columns where ";
            strSql += " table_name='" + tablename + "' AND  ";
            strSql += " column_name LIKE 'FILENAME%' ";

            DataSet ds = new DataSet();
            ds = DBUtility.OracleHelper.Query(strSql);
            if (ds.Tables[0].Rows.Count > 0)
            {
                for(int i=0;i<ds.Tables[0].Rows.Count;i++)
                {
                    column += ds.Tables[0].Rows[i]["name"].ToString() + ",";
                }
            }
            if (column != "")
            {
                column = column.Substring(0, column.Length - 1);
                strSql = "select  " + column + " from " + tablename + " where " + whereStr;
                ds = DBUtility.OracleHelper.Query(strSql);
            }
            return ds;

        }
        public string getFuJianName(string FuJianId)
        {
            string FuJianName = "";
            string strSql = "select name from accessoriesinfo where id='" + FuJianId + "'";


            OracleDataReader dr = DBUtility.OracleHelper.ExecuteReader(strSql);
            while (dr.Read())
            {
                FuJianName = dr["name"].ToString();
            }

            return FuJianName;
        }
    }
}
